"""
TODO: FX  & Sheets
    FX(path)    # visit all names for sheets in a file
        .sheets()   #Sheets
        .names()    # list[str] -> names
        .foreach(visit(name))

    FX(path)   # visit all sheet object for sheets in a file
        .sheets()   #Sheets
        .foreach(visit(sheet))   


TODO: Sheet & Reader
    FX(path)    # read all records of a sheet in a file
        .sheet(name)    #Sheet
        .reader()       #Sheet.Reader
        .read(visit(row, sheet)) #create_object_from_row(row, sheet)



TODO: Sheet & Writer
    FX(path)  # create Empty File only
        .touch()

    FX(path)    #create an File & a Empty sheet with name
        .sheet(sheet_name) # Sheet
        .touch()
                
    FX(path)    #create an File & many Empty sheet
        .sheets([sheet_names]) # Sheets
        .touch()

    FX(path)    # create an File , one sheet , many rows
        .sheet(sheet_name)
        .writer()
        .write(objects, object_to_row(object))
"""

#Sheet, Reader, Writer
class Sheets(object):
    pass

class Sheet(object):
    class Reader(object):
        pass
    class Writer(object):
        pass

class FileExcel(object):
    def __init__(self, path):
        self.__path = path

    def exits(self):
        pass

    def sheets(self):
        pass

    def sheet(self, name):
        pass




#TODO: inherit  Order.from_excel(path, sheet_name)
from abc import ABC, abstractmethod
class FromExcel(ABC):
    @classmethod
    @abstractmethod
    def from_excel(cls, path, sheet_name):
        print(f"FromExcel: path:{path}, sheet_name:{sheet_name}")
        return FromExcel(path, sheet_name)



    def __init__(self, path, sheet_name):
        self.__path = path
        self.__shee_name = sheet_name

    def path(self):
        return self.__path
    def shee_name(self):
        return self.__shee_name

    """

    def foreach(self, creator):
        excel = Excel(self.__path, self.__shee_name)
        result = []
        for row in excel.rows():
            result.append(creator)
        return result
    """


import unittest 
class TestFromExcel(unittest.TestCase):
    class Order(FromExcel):
        def __init__(self, no, name):
            self.__no = no
            self.__name = name
        def no(self):
            return self.__no
        def name(self):
            return self.__name

        def __str__(self):
            return "[no:{},name:{}]".format(self.no(), self.name())

        @classmethod
        def from_excel(cls, path, shee_name):
            #return Fx(path, sheet_name).forach_row(cls(no=row[0], name=row[1]))
            return [
                TestFromExcel.Order(no=1, name="hello"),
                TestFromExcel.Order(no=2, name="hello"),
            ]
            

    def test_from_excel(self):
        for order in TestFromExcel.Order.from_excel("./abc.xls", "sheet1"):
            print(str(order))
    
